package com.switz.agendacita.persistence;

import java.util.List;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils;
import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.stereotype.Repository;

import com.switz.agendacita.dto.EmpresaTipo;
import com.switz.agendacita.persistence.iface.EmpresaTipoDao;

@Repository
public class EmpresaTipoDaoImpl extends JdbcDaoSupport implements EmpresaTipoDao{
	
	@Autowired
	public EmpresaTipoDaoImpl(DataSource dataSource) {

        setDataSource(dataSource);
    }
	
	//multiples inserciones en la tabla empresatipo atravez de una lista
	@Override
	public void insertBatchEmpresaTipo(List empresaTipoList) {
		SimpleJdbcInsert simpleJdbcInsert = new SimpleJdbcInsert(
                getJdbcTemplate().getDataSource())
                .withTableName("empresatipo");

        SqlParameterSource[] array = SqlParameterSourceUtils.createBatch(empresaTipoList.toArray());

        simpleJdbcInsert.executeBatch(array);
		
	}

	
}
